package com.kcwx.generator.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kcwx.common.annotation.DataSource;
import com.kcwx.common.enums.DataSourceType;
import com.kcwx.generator.domain.GenTable;
import com.kcwx.generator.mapper.GenTableSqlServerMapper;
import com.kcwx.generator.mapper.GenTableMysqlMapper;

/**
 * 业务 服务层实现
 * 
 */
@Service
public class GenTableServiceImpl implements IGenTableService {
	@Autowired
	private GenTableSqlServerMapper genTableSqlserverMapper;

	@Autowired
	private GenTableMysqlMapper genTableMysqlMapper;

	/**
	 * 查询据库列表
	 * 
	 * @param tableNames 表名称组
	 * @return 数据库表集合
	 */
	@Override
	@DataSource(DataSourceType.GENERATOR)
	public List<GenTable> selectDbTableListByNames(String database, String[] tableNames) {
		switch (database) {
		case "sqlserver":
			return genTableSqlserverMapper.selectDbTableListByNames(tableNames);
		case "mysql":
			return genTableMysqlMapper.selectDbTableListByNames(tableNames);
		default:
			return genTableSqlserverMapper.selectDbTableListByNames(tableNames);
		}

	}
}